

import ia = module("main/org/sdmx/model/v2/base/IdentifiableArtefact");
import aaa = module("main/org/sdmx/model/v2/base/AnnotableArtefactAdapter");
import is = module("main/org/sdmx/model/v2/base/InternationalString");
import ut = module("utils/utils");

/**
	* Default implementation of the IdentifiableArtefact interface. 
	* This class exists as convenience for creating IdentifiableArtefacts 
	* objects.
	* 
	* @author Xavier Sosnovsky, Anthony Morel
	* 
	* @todo
	* 		o Create validators for id, uri and urn.
	* 		o The id should be optional.
	*/
export class IdentifiableArtefactAdapter extends aaa.AnnotableArtefactAdapter 
	implements ia.IdentifiableArtefact {
			
	/*==============================Fields================================*/
			
	private _id:string;
		
	private _uri:string;
		
	private _urn:string;
		
	private _name:is.InternationalString;
		
	private _description:is.InternationalString;
		
	/*===========================Constructor==============================*/
		
	/**
		* Constructs an identifiable artefact 
		* 
		* @param identifier
		* 		The object identifier
		*/
	constructor(identifier:string) {
		super();
		this.setId( identifier) ;
	}
		
	/*============================Accessors===============================*/
		
	/**
		* @inheritDoc 
		*/
	public getUrn():string {
        return this._urn;
	}
		
	/**
		* @inheritDoc 
		*/
	public setUrn(urn:string) {
		this._urn = urn;
	}
		
	/**
		* @inheritDoc 
		*/
	public getName():is.InternationalString {
		return this._name;
	}
		
	/**
		* @inheritDoc 
		*/
	public setName(name:is.InternationalString) {
		if (null != name && name.getLocalisedStrings().getLength() > 0) {
            this._name = name;
		}
	}
		
	/**
		* @inheritDoc 
		*/
	public getDescription():is.InternationalString {
        return this._description;
	}
		
	/**
		* @inheritDoc 
		*/
	public setDescription(description:is.InternationalString) {
		if (null != description && description.getLocalisedStrings().getLength() > 0){
            this._description = description;
		}
	}
		
	/**
		* @inheritDoc 
		*/
	public getUri():string {
        return this._uri;
	}
		
	/**
		* @inheritDoc 
		*/
	public setUri(uri:string) {
        this._uri = uri;
	}
		
	/**
		* @inheritDoc 
		*/
	public getId():string {
        return this._id;
	}
		
	/**
		* @inheritDoc 
		*/
	public setId(id:string) {
		if (null == id || "" == ut.Utils.trim(id)) {
			throw new Error("The id cannot be null or empty");
		} else {
            this._id = id;
		}
	}
}